// 截获键盘事件，如果是"Enter"键,则除当前控件是按钮或文本域之外,将其转换成"Tab"处理
document.onkeydown = function() {
	if (event.srcElement.type != "submit" && event.srcElement.type != "button"
			&& event.srcElement.type != "textarea"
			&& event.srcElement.type != "reset" && event.keyCode == 13) {
		event.keyCode = 9;
	}
}

/* This function is used to set cookies */
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value)
			+ ((expires) ? "; expires=" + expires.toGMTString() : "")
			+ ((path) ? "; path=" + path : "")
			+ ((domain) ? "; domain=" + domain : "")
			+ ((secure) ? "; secure" : "");
}

/* This function is used to get cookies */
function getCookie(name) {
	var prefix = name + "="
	var start = document.cookie.indexOf(prefix)

	if (start == -1) {
		return null;
	}

	var end = document.cookie.indexOf(";", start + prefix.length)
	if (end == -1) {
		end = document.cookie.length;
	}

	var value = document.cookie.substring(start + prefix.length, end)
	return unescape(value);
}

/* This function is used to delete cookies */
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + ((path) ? "; path=" + path : "")
				+ ((domain) ? "; domain=" + domain : "")
				+ "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function createForm(url, matrix) {
	var form = document.createElement("form");
	document.appendChild(form);
	form.method = "post";
	form.action = url;
	if (matrix == null)
		return form;
	for (var i = 0; i < matrix.length; i++) {
		var c = matrix[i];
		createFormElement("input", "hidden", c[0], c[0], c[1], form);
	}
	return form;
}

// This function is a generic function to create form elements
function createFormElement(element, type, name, id, value, parent) {
	var e = document.createElement(element);
	e.setAttribute("name", name);
	e.setAttribute("type", type);
	e.setAttribute("id", id);
	e.setAttribute("value", value);
	parent.appendChild(e);
}


window.onbeforeunload = function() {
	if (document.all("cookieForm")) {
		deleteCookie("quickGroup", "/", null);
		deleteCookie("tableAlias", "/", null);
		deleteCookie("tableName", "/", null);
		var celements = cookieForm.elements;
		for (var i = 0; i < celements.length; i++) {
			var celement = celements[i];
			setCookie(celement.name, celement.value, null, "/", null, null);
		}
	}
}


function go(i,j,k,w){
	if(j==0) return;
	if(i>k||i<=0){
//		alert("??");        
		return;
	}
	var url=window.pageUrl;
	if(window.pageUrl==null){
	  url=location.href;
	}
	
	var form=window.form;
  if(form==null){
    form=document.createElement("FORM");
    document.appendChild(form);
  }
  form.action=url;
  form.name="param_form_pub";
  form.method="post";
  var input1=document.createElement("<input type=hidden name=pageNo value='"+i+"'>");
  var input2=document.createElement("<input type=hidden name=rowsOfPage value='"+j+"'>");
  var input3=document.createElement("<input type=hidden name=quickWhere value=\""+w+"\">");
  form.appendChild(input1);
  form.appendChild(input2);
  form.appendChild(input3);
//  alert(form.outerHTML)
  form.submit();

}
// Show the document's title on the status bar
window.defaultStatus = document.title;
